﻿CREATE PROCEDURE [sp_ssiscatalog].[get_events]
		@exec_id									BIGINT												/*Specify which execution we want to return information for*/
,		@exec_events_packagesexcluded				NVARCHAR(MAX)		=	NULL						/*Specify a list of packages for which events should not be displayed*/
AS
BEGIN
		SET NOCOUNT ON;
		SELECT	[ResultSet]=N'EVENTS',em.[event_message_id],em.[message_time],em.[message],em.[package_name],em.[event_name],em.[message_source_name],em.[package_path],em.[execution_path],em.[event_message_context_xml]
		FROM	[sp_ssiscatalog].[events](@exec_id) em 
		WHERE	(		@exec_events_packagesexcluded IS NULL
				OR		CHARINDEX(em.[package_name],@exec_events_packagesexcluded) = 0
				)
		ORDER	BY em.[message_time] DESC;
		RAISERROR('%d events returned',1,1,@@ROWCOUNT);
		
END